/*
    Project: OCMF (Operant Chamber Management Framework)
    Version: 1.0
    Author: Copyright (C) 2010, Samuel Delaney & Andrew Harvey
    Licence:
        This file is part of OCMF.

            OCMF is free software: you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation, either version 3 of the License, or
            (at your option) any later version.

            OCMF is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.

            You should have received a copy of the GNU General Public License
            along with OCMF.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DBCLIENT_H
#define DBCLIENT_H

#include <QSize>
#include <QQueue>
#include <QSqlQuery>
#include <QVariant>
#include <QDateTime>
#include <QSqlError>
#include <QDebug>
#include <QLocale>
#include <QNetworkInterface>
#include <QHostInfo>
#include <QFile>
#include <QDir>

#include "Experiment.h"
#include "OcmfServerStatus.h"
#include "serverconfig.h"
#include "qsql_mysql.h"
#include "Logger.h"

class OcmfServer;

class DbClient
{
private:
    OcmfServer * ownerOcmfServer;
public:
    DbClient(OcmfServer *);
    ~DbClient();

    OcmfServer * OwnerOcmfServer();

    //
    void CleanDatabase();

    //retreives the first experiment scheduled for this server
    Experiment * GetNextExperiment();

    //inserts the experiment into the database
    void AddExperimentResult(QByteArray  * experimentResultBytes);

    //sets the status value of the server in the db which allows the client to be updated
    void SetServerStatus(OcmfServerStatus::Status ocmfServerStatus, Experiment * experiment);

protected:
    void run();
};

#endif // DBCLIENT_H
